const directions2D = [
  [-1, -1],
  [0, -1],
  [1, -1],
  [-1, 0],
  [0, 0],
  [1, 0],
  [-1, 1],
  [0, 1],
  [1, 1],
]

const generateMovementKeyMap = (...mappings) => {
  const res = {};
  for (let mapping of mappings) {
    if (typeof mapping === 'string')
      mapping = mapping.split('');
    mapping.forEach((key: string, i) => {
      res[key] = [...directions2D[i], 0];
    });
  }
  res['<'] = [0, 0, 1];
  res['>'] = [0, 0, -1];
  return res;
};

export const movementKeys = generateMovementKeyMap(
  'ykuh.lbjn', // vi-keys
  'qweasdzxc',
  ['Home', 'ArrowUp', 'PageUp', 'ArrowLeft', 'Unidentified', 'ArrowRight', 'End', 'ArrowDown', 'PageDown'], // numpad (numlock must be off)
  ['Home', 'ArrowUp', 'PageUp', 'ArrowLeft', 'Clear', 'ArrowRight', 'End', 'ArrowDown', 'PageDown'], // numpad for blink/chromium: 5 is identified as Clear
);
